1379B - Dubious Cyrpto - CodeForces Solution


binary search brute force math number theory *1500

Please click on ads to support us..

C++ Code:

#include<bits/stdc++.h>
using namespace std;
template<typename... T>
void see(T&... args) { ((cin >> args), ...);}
template<typename... T>
void put(T&&... args) { ((cout << args << " "), ...);}
template<typename... T>
void putl(T&&... args) { ((cout << args << " "), ...); cout<<'\n';}
#define error(args...) { string _s = #args; replace(_s.begin(),     _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {cerr << *it << "=" << a << ", "; err(++it, args...);}
// #define int long long
#define pb push_back
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pll pair<ll,ll>
#define vl vector<ll>
#define vll vector<pll>
#define vc vector
#define mii map<int,int>
#define mll map<ll,ll>
#define mli map<ll,int>
#define mil map<int,ll>
#define umii unordered_map<int,int>
#define umll unordered_map<ll,ll>
#define umli unordered_map<ll,int>
#define umil unordered_map<int,ll>
#define L cout<<'\n';
#define E cerr<<'\n';
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for (int i=a; i<b; ++i)
#define rev(i,a,b) for (int i=a; i>b; --i)
#define revc(i,a,b,c) for (int i=a; i>b; i-=c)
#define repc(i,a,b,c) for (int i=a; i<b; i+=c)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define setpr(x) cout<<setprecision(x)<<fixed
#define sz size()
#define seea(a,x,y) for(int i=x;i<y;i++){cin>>a[i];}
#define seev(v,n) for(int i=0;i<n;i++){int x; cin>>x; v.push_back(x);}
#define sees(s,n) for(int i=0;i<n;i++){int x; cin>>x; s.insert(x);}
const ll inf = INT_MAX;
const ld ep = 0.0000001;
const ld pi = acos(-1.0);
const int M = 1e9 + 7;
const ll N = 2e5+1;
const int N1 = 101;
const ll modi = 998244353;
vi child[N];
vi primes;
int spf[N];
int mp[N];
int pvisited[N];
int visited[N];
int parent[N];
int logt[1010];
void solve();
void calSPF();
ll ncr(ll n,ll r);
ll NCR[N][N1];
ll calPow(ll a, ll p);
void dfs(int r,int t);
int main(){
    int t = 1;
    see(t);
    while(t--) solve();
}
 
void solve(){
    ll l,r,m;
    see(l,r,m);
    ll dif = r - l;
    rep(i,l,r+1){
        if(m>=i&&m%i <= dif){
            putl(i,l+ (m%i),l);
            return;
        }else if((i - m%i)<=dif){
            putl(i,l,l + (i - m%i));
            return;
        }
    }
}
 


Comments

Submit
0 Comments
More Questions

1647A - Madoka and Math Dad
710A - King Moves
1131A - Sea Battle
118A - String Task
236A - Boy or Girl
271A - Beautiful Year
520B - Two Buttons
231A - Team
479C - Exams
1030A - In Search of an Easy Problem
158A - Next Round
71A - Way Too Long Words
160A - Twins
1A - Theatre Square
1614B - Divan and a New Project
791A - Bear and Big Brother
1452A - Robot Program
344A - Magnets
96A - Football
702B - Powers of Two
1036A - Function Height
443A - Anton and Letters
1478B - Nezzar and Lucky Number
228A - Is your horseshoe on the other hoof
122A - Lucky Division
1611C - Polycarp Recovers the Permutation
432A - Choosing Teams
758A - Holiday Of Equality
1650C - Weight of the System of Nested Segments
1097A - Gennady and a Card Game